package com.csw.shuanfa.CodeImprove.CompleteFutureLinkedBlockingQueue.oldtest.ThreadXiangMu;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

import static java.lang.Thread.sleep;

/**
 * 打断 park 线程, 不会清空打断状态
 */
@Slf4j
public class Interrupted3 {

    public static void main(String[] args) throws InterruptedException {
        test3();
    }

    private static void test3() throws InterruptedException {
        Thread t1 = new Thread(() -> {
            log.info("" + "park...");
            LockSupport.park();
            log.info("" + "unpark...");
            log.info("" + "打断状态：{}" + Thread.currentThread().isInterrupted());
        }, "t1");
        t1.start();
        sleep((long) 0.5);
        t1.interrupt();
    }
}
